<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the  Academic Free License (AFL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to support@zprofess.com so we can send you a copy immediately.
 *
 * @category   	Prestashop module
 * @package		Help Desk
 * @version 	1.0
 * @author 		Kurosaki <kurosaki@zprofess.com>
 * @copyright   Copyright (c) 2012 ZPROFESS. (http://zprofess.com)
 * @license    	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/classes/ZticketObject.php');
/**
 * When rating for content
 */
if (isset($_GET['rating'])) {
	$id_ticket = $_GET['id_ticket'];
	$id_content = $_GET['id_content'];
	$id_customer = $_GET['id_customer'];
	$value = $_GET['value'];
	$rs = Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute('
		UPDATE `ps_zhelpdesk_ticket_content` SET `id_zhelpdesk_ticket_rating`='.$value.'  
		WHERE (`id_zhelpdesk_ticket_content`='.$id_content.') AND (`id_zhelpdesk_ticket`='.$id_ticket.')
	');
	$rs = Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute('
		UPDATE `ps_zhelpdesk_ticket_content` SET `id_customer_rating`='.$id_customer.'  
		WHERE (`id_zhelpdesk_ticket_content`='.$id_content.') AND (`id_zhelpdesk_ticket`='.$id_ticket.')
	');
	
	if ($rs==true)
		echo 'OK';
	else 
		echo 'NO';
}
